package Json;

import com.google.gson.Gson;

/**
 * @author Ajie
 * @date 2021-02-06
 * @function 测试 json 转换中 数组 是否需要特殊转化
 * 结果：不需要。
 * result:123.66
 * result:4.6546545E9
 */
public class GsonFloatArrays {
    public static void main(String[] args) {
        int num =2;
        System.out.println(((float)num));

        MaskData temp = new MaskData();
        float[] floats = new float[]{123.66f,4654654654.5f};
        temp.path = 1234567890123L;
        temp.faceLandMarks = floats;

        Gson gson = new Gson();
        String s = gson.toJson(temp);

        MaskData temp1 = new Gson().fromJson(s, MaskData.class);

        for (int i = 0; i < temp1.faceLandMarks.length; i++) {
            System.out.println("result:"+temp1.faceLandMarks[i]);
        }
        System.out.println("path:"+temp1.path);


    }

    private static class MaskData {
        long path;
        int imageWidth;
        int imageHeight;
        float[] faceLandMarks;
    }
}
